<template>

  <div class="CpersonalCenter">
    <!-- 头部 -->
    <div class="cpersonal_top">
    	<div class="cpersonal_top_l"><img width="216" height="57" src="~/assets/img/logo.png"></div>
    	<div class="cpersonal_top_r">
    		<div class="seek">
    			<div class="cal_input" @click="zkss"><input type="text" placeholder="搜索所需服务，如公司注册" readonly="readonly" /></div>
    			<ul class="cal_list">
    				<li v-for="(dt,id) in title.nav.oneTwoServiceData[0].twoServiceRes"><a :href="'/ServiceDetails/'+dt.id+'?name='+dt.id" target="_blank">{{dt.servicename}}</a></li>
    				<li v-for="(dt,id) in title.nav.oneTwoServiceData[1].twoServiceRes"><a :href="'/ServiceDetails/'+dt.id+'?name='+dt.id" target="_blank">{{dt.servicename}}</a></li>
    				<li v-for="(dt,id) in title.nav.oneTwoServiceData[2].twoServiceRes"><a :href="'/ServiceDetails/'+dt.id+'?name='+dt.id" target="_blank">{{dt.servicename}}</a></li>
    				<li v-for="(dt,id) in title.nav.oneTwoServiceData[3].twoServiceRes"><a :href="'/ServiceDetails/'+dt.id+'?name='+dt.id" target="_blank">{{dt.servicename}}</a></li>
    				<li v-for="(dt,id) in title.nav.oneTwoServiceData[4].twoServiceRes"><a :href="'/ServiceDetails/'+dt.id+'?name='+dt.id" target="_blank">{{dt.servicename}}</a></li>
    			</ul>

    		</div>
    		<div class="side">
    			<div class="userimg"><img :src="'https://exam.zhonghaiqihang.com/'+title.gr.avatar"></div>
    			<!--  -->
    			<div class="username">
    				<p class="top">{{title.gr?title.gr.username:'用户名'}}<i class="jiantou"></i></p>
    				<ul class="list">
    					<li><a href="/CpersonalCenter/Cmall?idx=1">我要购买</a></li>
    					<li><a href="/CpersonalCenter/Cmodify?idx=6">账号管理</a></li>
    					<li><a href="JavaScript:;" @click="tcdl('userinfoRes','',-1)">退出</a></li>
    				</ul>

    			</div>
    		</div>
    	</div>
    </div>
    <!-- 头部 -->
    <div class="cpersonal_content">
    	<!-- 左边导航 -->
    	<div class="cpersonal_left">
    		<ul class="cal_left_list">
          <!--  -->
          <li v-for="(item,index) in navlist" @click="on(item.url,index)" :class="index==$route.query.idx?'on':''">
            <i :class="'i'+(index+1)"></i><span>{{item.text}}</span>
          </li>
<!--    	<li @click="on()" class="on"><i class="i1"></i><span>个人中心首页</span></li>
    			<li @click="on()"><i class="i2"></i><span>展示位管理</span></li>
    			<li @click="on()"><i class="i3"></i><span>来电中心</span></li>
    			<li @click="on()"><i class="i4"></i><span>我的钱包</span></li>
    			<li @click="on()"><i class="i5"></i><span>订单中心</span></li>
    			<li @click="on()"><i class="i6"></i><span>我的收藏</span></li>
    			<li @click="on()"><i class="i7"></i><span>账号信息</span></li> -->
    		</ul>
    	</div>
    	<!-- 左边导航 -->
    	<!--  右侧内容-->
      <nuxt />
    	<!-- 右侧内容 -->
    </div>
  </div>


</template>

<script>
  import axios from 'axios';
  import $ from 'jquery';
  export default {
    name: 'HelloWorld',
    data () {
      return {
        idx:0,
        navlist:[
          {text:"个人中心首页",url:"/CpersonalCenter"},
          {text:"展示位管理",url:"/CpersonalCenter/Cmall"},
          {text:"来电中心",url:"/CpersonalCenter/Ccall"},
          {text:"我的钱包",url:"/CpersonalCenter/Cwallet"},
          {text:"订单中心",url:"/CpersonalCenter/corder"},
          {text:"我的收藏",url:"/CpersonalCenter/Ccollection"},
          {text:"账号信息",url:"/CpersonalCenter/Cmodify"},
          ]
      }
    },
    async asyncData ({ req,params }) {
    let nh = await axios.get(`https://exam.zhonghaiqihang.com/PInterface/Header/headerData`);
    let nh2 = await axios.get(`https://exam.zhonghaiqihang.com/PInterface/Index/indexData`);
    let a = req.headers.cookie;
    let cookie = '';
    if(a.indexOf('userinfoRes')!=-1){
      let b = a.split('userinfoRes=');
      let c = b[1].split(';');
      cookie = c[0];
    }
    let gr = await axios.get(`https://exam.zhonghaiqihang.com/PInterface/UserCenter/userCenterIndexData?userid=`+cookie)

    let nh3 = await axios.get(`https://exam.zhonghaiqihang.com/PInterface/Special/specialData`,{
      params:{
        serviceid:'44'
      }});
    let nh4 = await axios.get(`https://exam.zhonghaiqihang.com/PInterface/Receptionist/receptionistData`);
    let nh6 = await axios.get(`https://exam.zhonghaiqihang.com/PInterface/UserCenter/allShowNumOrder`,{
      params:{
        userid:1
      }});
    let nh7 = await axios.get(`https://exam.zhonghaiqihang.com/PInterface/UserCenter/inDisplayShowNumOrder`,{
      params:{
        userid:1
      }});
    let nh8 = await axios.get(`https://exam.zhonghaiqihang.com/PInterface/UserCenter/overdueShowNumOrder`,{
      params:{
        userid:1
      }});
    let data  = {nav:nh.data,index:nh2.data,zym:nh3.data,gj:nh4.data,all:nh6.data,zsz:nh7.data,gq:nh8.data,gr:gr.data};
    return { title: data}
  },
  mounted:function(){

    $('.tbnava1').addClass('select');
    function setCookie(cname,cvalue,exdays)
    {
      var d = new Date();
      d.setTime(d.getTime()+(exdays*24*60*60*1000));
      var expires = "expires="+d.toGMTString();
      document.cookie = cname + "=" + cvalue + "; " + expires;
    }
    if(this.$route.query.name == 'Ccall'){
       this.$router.push('/');
       setCookie('userinfoRes','',-1);
    }
    if(this.$route.query.name == 'Cmall'){
      this.$router.push('/');
      setCookie('userinfoRes','',-1);
    }
    if(this.$route.query.name == 'Cwallet'){
      this.$router.push('/');
      setCookie('userinfoRes','',-1);
    }
    if(this.$route.query.name == 'corder'){
      this.$router.push('/');
      setCookie('userinfoRes','',-1);
    }
    if(this.$route.query.name == 'Ccollection'){
      this.$router.push('/');
      setCookie('userinfoRes','',-1);
    }
    if(this.$route.query.name == 'Cmodify'){
      this.$router.push('/');
      setCookie('userinfoRes','',-1);
    }

     if(this.title.gr == 'go_signin'){
       this.$router.push('/Login');
       setCookie('userinfoRes','',-1);
     }else if(this.title.gr == 'userid_error'){
       this.$router.push('/Login');
       setCookie('userinfoRes','',-1);
     }else if(this.title.gr == 'userinfo_is_null'){
       this.$router.push('/Login');
       setCookie('userinfoRes','',-1);
     }else if(this.title.gr == 'userinfo_banuse'){
       this.$router.push('/Login');
       setCookie('userinfoRes','',-1);
     }
     else if(this.title.gr == 'serviceid_is_null'){
       window.open('/Mall',_self);
     } else if(this.title.gr == 'serviceid_error'){
       window.open('/Mall',_self);
     }else if(this.title.gr == 'serviceinfo_is_null'){
       window.open('/Mall',_self);
     }else if(this.title.gr == 'serviceinfo_banuse'){
       window.open('/Mall',_self);
     }
    // var domain = window.location.href;

    $(document).ready(function(){
      $('.hh-xgzl .div .bj').click(function(){
        $(this).toggleClass('select');
        $(this).siblings('strong').toggleClass('select');
        $(this).parent().siblings('.ycd').toggleClass('select');
        $(this).parent().siblings('.tx').toggleClass('select');
        if($(this).text()=='编辑'){
          $(this).html('展开<i></i>');
        }else if($(this).text()=='展开'){
          $(this).html('编辑<i></i>');
        }
      });
      $('.hh-grzx .left li').click(function(){
        $('.hh-grzx .left li').removeClass('select');
        $(this).addClass('select');
      });

      $('.hh-xgzl .div .bc').click(function(){
        $(this).parent().parent().children('strong').removeClass('select');
        // $(this).parent().parent().children('.bj').html('编辑<i></i>');
        // $(this).parent().removeClass('select');

      });
      $(document).ready(function () {
        $('.htcfw').hide();
      });


    })

  },
  computed: {
    loadList() {
      return (type) => {
        let newData = [];
        this.title.nav.threeServiceData.forEach(item => {
          if(item.pid == type) {
          newData.push(item);
        }
      });
        return newData;
      };
    }
  },head () {
    return {
      title: '个人中心-企业邦',
      meta: [
        { hid: 'description', name: 'description', content:'个人中心-企业邦'},
        { hid: 'keywords', name: 'keywords', content:'个人中心-企业邦'}
      ]
    }
  },methods:{

    on:function(e,idx){
      this.idx = idx
      window.open(e+'?idx='+idx,'_self')
    },
    tc:function(e1,e2,e3){
      var d = new Date();
      d.setTime(d.getTime()+(e3*24*60*60*1000));
      var expires = "expires="+d.toGMTString();
      document.cookie = e1 + "=" + e2 + "; " + expires;
      this.$router.push('/');
    },

    tzlj:function(e){
      // const new3 = this.$router.resolve({name: e});
      // window.open(new3.href,'_self');
      this.$router.push('/'+e);
    },
    tzlj1:function(e){
      // const new3 = this.$router.resolve({name: this.dhlj[e]});
      // window.open(new3.href,'_self');
      this.$router.push(e);
    },
    cao:function(e1,e2){
      this.chuandi = e1;
      var _this = this;
        _this.$router.push(e2);
    },
    tcdl:function(e1,e2,e3){
      if(this.$route.query.idx == 2){
        window.open('/CpersonalCenter?idx=0&name=Ccall','_self')
      }else if(this.$route.query.idx == 1){
        window.open('/CpersonalCenter?idx=0&name=Cmall','_self')
      }else if(this.$route.query.idx == 3){
        window.open('/CpersonalCenter?idx=0&name=Cwallet','_self')
      }else if(this.$route.query.idx == 4){
        window.open('/CpersonalCenter?idx=0&name=corder','_self')
      }else if(this.$route.query.idx == 5){
        window.open('/CpersonalCenter?idx=0&name=Ccollection','_self')
      }else if(this.$route.query.idx == 6){
        window.open('/CpersonalCenter?idx=0&name=Cmodify','_self')
      }else{
        var d = new Date();
        d.setTime(d.getTime()+(e3*24*60*60*1000));
        var expires = "expires="+d.toGMTString();
        document.cookie = e1 + "=" + e2 + "; " + expires;
        window.open('/','_self')
      }

    },
    xqymtz:function(e1,e2){

      let href = '/ServiceDetails/'+e1+'?name='+e2;
      window.open(href,'_blank');
    },zkss:function(){
      $('.cal_list').toggleClass('select');
    }
    ,zymtz:function(e,e2,e3){
      let a = window.location.href;
      let a1 = a.split('CpersonalCenter/');
      this.chuandi = e3;

      if(a1 == 'https://localhost:3000/CpersonalCenter'||a1 == 'https://www.qiyebang.net.cn/CpersonalCenter'){
        window.open(e2,'_self')
      }else{
        let a2 = a1[1].split('?');
        let a3 = a2[0];
        if(e == a3){
          this.$router.push(e2);
        }else{
          window.open(e2,'_self')

        }
      }


    }
  }
  }
</script>

<style>

</style>
